package com.db.nio;

import java.io.*;
import java.net.Socket;

public class NetworkCopyIOClient extends AbstractCopy {
    public static void main(String[] args) {
        System.out.println("client started");

        try (Socket socket = new Socket(SERVER_HOST, SERVER_PORT);
             OutputStream outputStream = socket.getOutputStream();
             InputStream inputStream = new FileInputStream(FILE_1)) {

            System.out.println("connection started");

            byte[] data = new byte[BUFFER_SIZE];
            while ((inputStream.read(data)) != -1) {
                outputStream.write(data);
            }

            System.out.println("success");

        } catch (IOException e) {
            System.out.println("input output exception");
        }
    }
}
